Skip to content

Static invoice server #3628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

valentinewallace
Copy link
Contributor

As part of supporting async payments, we want to support serving static invoices on behalf of an often-offline payee, in response to invoice requests from payers.

See this doc for more details on the protocol. Here we implement the server-side of the linked protocol.

Based on #3618

@valentinewallace valentinewallace force-pushed the 2025-02-static-invoice-server branch from 1c6073b to 4a287ea Compare May 29, 2025 16:58
Copy link

codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 40.42553% with 28 lines in your changes missing coverage. Please review.

Project coverage is 88.83%. Comparing base (6771d84) to head (2dc0bc6).

Files with missing lines Patch % Lines
lightning/src/util/test_utils.rs 52.17% 7 Missing and 4 partials ⚠️
lightning/src/offers/static_invoice.rs 0.00% 9 Missing ⚠️
lightning/src/offers/invoice.rs 0.00% 3 Missing ⚠️
lightning/src/offers/invoice_macros.rs 0.00% 3 Missing ⚠️
lightning/src/ln/channelmanager.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3628      +/-   ##
==========================================
- Coverage   88.88%   88.83%   -0.06%     
==========================================
  Files         165      165              
  Lines      118886   118931      +45     
  Branches   118886   118931      +45     
==========================================
- Hits       105676   105650      -26     
- Misses      10892    10948      +56     
- Partials     2318     2333      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@valentinewallace valentinewallace force-pushed the 2025-02-static-invoice-server branch 4 times, most recently from 23f3276 to 706e277 Compare June 10, 2025 21:18
In upcoming commits, we need to check whether a static invoice or its underlying
offer is expired in no-std builds. Here we expose the methods to do so. The
methods could instead be kept private to the crate, but they seem potentially
useful.
@valentinewallace valentinewallace force-pushed the 2025-02-static-invoice-server branch from 706e277 to f5a78e4 Compare June 30, 2025 22:46
@valentinewallace valentinewallace marked this pull request as ready for review June 30, 2025 22:46
As part of serving static invoices to payers on behalf of often-offline
recipients, these recipients need a way to contact the static invoice server to
retrieve blinded paths to include in their offers.

Add a utility to create blinded paths for this purpose as a static invoice
server. The recipient will be configured with the resulting paths and use them
to request offer paths on startup.
As part of serving static invoices to payers on behalf of often-offline
recipients, we need to provide the async recipient with blinded message paths
to include in their offers.

Support responding to inbound requests for offer paths from async recipients.
As part of serving static invoices to payers on behalf of often-offline
recipients, the recipient will send us the final static invoice once it's done
being interactively built. We will then persist this invoice and confirm to
them that the corresponding offer is ready to be used for async payments.

Surface an event once the invoice is received and expose an API to tell the
recipient that it's ready for payments.
Here we implement serving static invoices to payers on behalf of often-offline
recipients. These recipients previously encoded blinded paths terminating at
our node in their offer, so we receive invoice requests on their behalf.

Handle those inbound invreqs by retrieving a static invoice we previously
persisted on behalf of the payee, and forward it to the payer as a reply to
their invreq.
We're about to add a bunch more async payments tests, so take this opportunity
to clean up the existing tests by no longer hardcoding the keysend payment
preimage bytes ahead of time. This previously caused an MPP test to spuriously
fail because all the session_privs were the same, and is generally not ideal.

Also add a few comments to an existing test and a few more trivial cleanups.
We were manually creating the static invoice in tests, but now we can use the
static invoice server protocol to interactively build the invoice.
@valentinewallace valentinewallace force-pushed the 2025-02-static-invoice-server branch from f5a78e4 to 2dc0bc6 Compare June 30, 2025 23:27
@valentinewallace
Copy link
Contributor Author

Still need to write a handful of tests but this should be good for a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants